import { useData } from "@sker/runtime"
import { toFail, toSuccess, useEntityManager } from "@sker/core"
import { KsAccount, KsLiveRoom, KsRedPacket } from "@sker/entities"
import { z } from "zod"


export default async () => {
    return await useEntityManager(async m => {
        const list = await m.createQueryBuilder()
            .select('account.user_id', 'user_id')
            .from(KsAccount, 'account')
            .where(`account.status=:status`, { status: '0' })
            .limit(1)
            .orderBy(`random()`)
            .execute()
        if (list && list.length) {
            const item = list[0]
            return toSuccess(item)
        }
        return toFail(`没有了`)
    })
}